/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cargui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author Pro
 */
public class CarsCrossingFrame extends JFrame {

    private CarsDisplay carsDisplay;
    private JButton runPause,Exit,Hlanes,Vlanes,HcarChance,VcarChance;

    public CarsCrossingFrame() {

        Hlanes = new JButton("Horizontal Lanes");
        Vlanes = new JButton("Vertical Lanes");
        HcarChance = new JButton("Horizontal Car Chance");
        VcarChance = new JButton("Vertical Car Chance");
        runPause = new JButton("Run/Pause");
        Exit = new JButton("Exit");

        carsDisplay = new CarsDisplay();

        setTitle("Cars Crossing, not crashing.. :-{");

        JPanel mainFrame = new JPanel();
        add(mainFrame);

        mainFrame.setLayout(new BorderLayout());

        JPanel display = new JPanel();
        JPanel buttonsPanel = new JPanel();

        mainFrame.add(carsDisplay, BorderLayout.CENTER);
        mainFrame.add(buttonsPanel, BorderLayout.SOUTH);

        buttonsPanel.add(Hlanes);
        buttonsPanel.add(Vlanes);
        buttonsPanel.add(HcarChance);
        buttonsPanel.add(VcarChance);
        buttonsPanel.add(runPause);
        buttonsPanel.add(Exit);

        pack(); // BUILD!! RAWR!!!

         Exit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {

                System.out.println("Exited properly yay");
                System.exit(0);
            }
        });


        this.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {

                System.out.println("Use Exit button next time please.");
                System.exit(0);
            }
        });

    }
}
